/**
 *
 * @author ilya portnyagin iportnyagin@gmail.com
 */

package ru.portnyagin.helpdeskru.service;

import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import ru.portnyagin.helpdeskru.model.StateRequest;

@Stateless
public class StateRequestService extends AbstractService<StateRequest> {
    @PersistenceContext(unitName = "HelpDeskRuPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public StateRequestService() {
        super(StateRequest.class);
    }
    
    public void findMapStateRequest(Map<String, StateRequest> map) {
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<StateRequest> z = cq.from(StateRequest.class);
        cq.select(z);
        
        List<StateRequest>x = em.createQuery(cq).getResultList();
        
        for(StateRequest xx: x) {
            map.put(xx.getId(), xx);
        }
        
    }
  
    

   
}
